﻿@page "/Orders"
@using Microsoft.AspNetCore.Authorization
@using maERP.SharedUI.Models.Order

@attribute [Authorize]

<PageTitle>Bestellungen</PageTitle>

<MudStack Row="true" Class="mb-8">
    <MudText Typo="Typo.h4">Bestellungen</MudText>
    <MudSpacer />
    <MudIconButton Icon="@Icons.Material.Filled.Add" Color="Color.Primary" Href="/Orders/Add" />
</MudStack>

<MudDataGrid T="OrderListVM" SortMode="SortMode.Single" Class="mb-8" ServerData="LoadGridData">
    <ToolBarContent>
        @*<MudText Typo="Typo.h6">Periodic Elements</MudText>*@
        <MudSpacer />
        <MudTextField @bind-Value="_searchString" TextChanged="this.Search" Placeholder="Suche" Adornment="Adornment.Start" Immediate="true" AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" Class="mt-0"></MudTextField>
    </ToolBarContent>
    <Columns>
        <PropertyColumn Property="x => x.Id" Title="Bestellnr." />
        <PropertyColumn Property="x => x.DateOrdered" Title="Datum" />
        <PropertyColumn Property="x => x.FullName" Title="Kunde" />
        <PropertyColumn Property="x => x.Total" Title="Summe" Format="C" />
        <PropertyColumn Property="x => x.Status" Title="Status" />
        <PropertyColumn Property="x => x.PaymentStatus" Title="Zahlstatus" />
        <TemplateColumn CellClass="d-flex justify-end">
            <CellTemplate>
                <MudIconButton Icon="@Icons.Material.Outlined.FindInPage" Href="@($"/Orders/{context.Item.Id}")" Size="@Size.Small" Color="@Color.Primary"></MudIconButton>
                <MudIconButton Icon="@Icons.Material.Outlined.Edit" Href="@($"/Orders/{context.Item.Id}/Edit")" Size="@Size.Small" Color="@Color.Primary"></MudIconButton>
            </CellTemplate>
        </TemplateColumn>
    </Columns>
    <PagerContent>
        <MudDataGridPager T="OrderListVM" />
    </PagerContent>
</MudDataGrid>